#include <glib.h>

void my_int_printf(gpointer data, gpointer user_data)
{
    g_printf("%s: value=%d user_data=%s\n", __FUNCTION__, *(int *)(data), (char *)user_data);
}

static void test_slist_reverse (void)
{
    GSList *slist = NULL;
    GSList *st;
    gint    nums[5] = { 1, 2, 3, 4, 5};
    gint    i;

    for (i = 0; i < 5; i++) {
        slist = g_slist_append (slist, &nums[i]);
    }

    g_print("\n");

    g_slist_foreach(slist, my_int_printf, "before reverse");

    slist = g_slist_reverse (slist);

    g_slist_foreach(slist, my_int_printf, "after reverse");

    g_slist_free (slist);
}


gint main (gint argc, gchar *argv[])
{
    g_test_init (&argc, &argv, NULL);

    g_test_add_func ("/slist/reverse", test_slist_reverse);

    return g_test_run ();
}
